brewery
notashelf /
1ceb889a1649a7b4b00bd23907b8fed8a6d30b9b

nixir

public

Import-resolving Nix IR plugin

Star0tarball
clone
ssh://git@git.notashelf.dev:33/notashelf/nixir.git

Commit 1ceb889a1649

tarball

NotAShelf <raf@notashelf.dev> · 2026-04-24 20:13 UTC

unverified2 files changed+16-3
irc: add timing measurements; formatting

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Id4402547e18b6569464850c3753383396a6a6964
diff --git a/src/irc/serializer.cpp b/src/irc/serializer.cppindex f5b1982..73051a7 100644--- a/src/irc/serializer.cpp+++ b/src/irc/serializer.cpp@@ -388,7 +388,7 @@ struct Deserializer::Impl {       uint32_t num_elements = read_u32();       std::vector<std::shared_ptr<Node>> elements;       elements.reserve(num_elements);-for (uint32_t i = 0; i < num_elements; i++) {+      for (uint32_t i = 0; i < num_elements; i++) {         elements.push_back(read_node());       }       return std::make_shared<Node>(ListNode(std::move(elements), line));diff --git a/src/plugin.cpp b/src/plugin.cppindex 18a832c..4a821f5 100644--- a/src/plugin.cpp+++ b/src/plugin.cpp@@ -12,6 +12,7 @@ #include "irc/serializer.h" #include "irc/types.h" +#include <chrono> #include <iostream>  namespace nix_ir_plugin {@@ -29,6 +30,8 @@ static void prim_loadIR(EvalState& state, const PosIdx pos, Value** args, Value&    std::string pathStr(path); +  auto t_start = std::chrono::high_resolution_clock::now();+   Deserializer deserializer;   IRModule module; @@ -38,6 +41,8 @@ static void prim_loadIR(EvalState& state, const PosIdx pos, Value** args, Value&     state.error<EvalError>("failed to deserialize IR bundle: %s", e.what()).atPos(pos).debugThrow();   } +  auto t_deser = std::chrono::high_resolution_clock::now();+   if (!module.entry) {     state.error<EvalError>("IR bundle has no entry point").atPos(pos).debugThrow();   }@@ -48,6 +53,14 @@ static void prim_loadIR(EvalState& state, const PosIdx pos, Value** args, Value&   } catch (const std::exception& e) {     state.error<EvalError>("failed to evaluate IR: %s", e.what()).atPos(pos).debugThrow();   }++  auto t_eval = std::chrono::high_resolution_clock::now();++  auto deser_us = std::chrono::duration_cast<std::chrono::microseconds>(t_deser - t_start).count();+  auto eval_us = std::chrono::duration_cast<std::chrono::microseconds>(t_eval - t_deser).count();++  std::cerr << "nixIR timing: deser=" << deser_us << "us eval=" << eval_us+            << "us total=" << (deser_us + eval_us) << "us" << std::endl; }  /**@@ -139,7 +152,7 @@ static RegisterPrimOp rp_info({  } // namespace nix_ir_plugin -// Plugin initialization message+// Plugin initialization __attribute__((constructor)) static void init_plugin() {-  std::cerr << "nix-ir-plugin loaded" << std::endl;+  // Plugin loads silently... }