Skip to content

Add option to compile (external) schema by cmake#31

Merged
aothms merged 4 commits into
IfcOpenShell:masterfrom
aothms:cmake_compile_schema
Feb 18, 2016
Merged

Add option to compile (external) schema by cmake#31
aothms merged 4 commits into
IfcOpenShell:masterfrom
aothms:cmake_compile_schema

Conversation

@aothms

@aothms aothms commented Feb 15, 2016

Copy link
Copy Markdown
Member

The idea is to simplify generating IfcOpenShell code for custom developed schemas, e.g [1] [2]. The added CMake code checks for dependencies in the python executable (pyparsing) and invokes the two steps necessary to compile an express schema into cpp. Generated files are added to the IfcParse project.

[1] https://bitbucket.org/Vertexwahn/bug-reports/downloads/IFC4_P6_longform_draft5_withMinorSyntaxCorrection.exp
[2] https://raw.githubusercontent.com/DURAARK/IFCPointCloud/master/tool/schemas/IFC2X3_TC1_PC.exp

@aothms

aothms commented Feb 15, 2016

Copy link
Copy Markdown
Member Author

@Stinkfist0 thoughts? It touches some of your recent changes. Maybe you have some ideas?

@Stinkfist0

Copy link
Copy Markdown
Contributor

Sure, I can see this might be handy for some. IMHO, the PYTHON_EXECUTABLE biz could be removed and we could assume (and instruct, if this was not instructed yet) that the correct Python must be set to path prior to the CMake run on all platforms (I made the CMake script to abort if Python features were wanted but Python was not in PATH).

@Stinkfist0

Copy link
Copy Markdown
Contributor

BTW just noticed that when I added removal of unused IFC revision source files from the project they're still copied as a part of the installation phase.

@aothms

aothms commented Feb 16, 2016

Copy link
Copy Markdown
Member Author

Well, the PYTHON_EXECUTABLE is anyway for making sure that IfcOpenShell gets installed into the correct directory. Right now [1] just a random Python is picked from the path, which may be completely unrelated to the PYTHON_INCLUDE_DIR and PYTHON_LIBRARY provided during the build. In fact, let me make an issue for that [2].

[1] https://github.com/IfcOpenShell/IfcOpenShell/blob/master/src/ifcwrap/CMakeLists.txt#L58
[2] #32

Thanks for noting the installation files issue [3]. I will fix it in this branch to prevent conflicts.

[3] https://github.com/IfcOpenShell/IfcOpenShell/blob/master/cmake/CMakeLists.txt#L355

@Stinkfist0

Copy link
Copy Markdown
Contributor

In the original script I have used a "standard" (I think official Python docs instruct to set this) PYTHONPATH for the location of python.exe. However, PYTHONPATH is appended to PATH, not prepended, which might be better. I don't mind having explicit control for setting the executable (I think in some projects I have seen problems at least on OS X for picking Python 2 vs 3) as long as it's used for all platforms.

@aothms

aothms commented Feb 17, 2016

Copy link
Copy Markdown
Member Author

I thought the PYTHONPATH env var is related to python modules, but I must admit I don't know the details, especially if several different interpreters are installed on the system.

The cmake find_library can be a can of worms, but I am under the impression that it should take care of resolving this in a cross-platform manner. It does seem I need to find the PythonInterp [1] package though (I will do that). I was under the impression that PythonLibs already would set the PYTHON_EXECUTABLE. Unfortunately the docs are not very elaborate on the inner workings of find_package(PythonInterp) neither do I find the source [2] very illustrative. pythonOCC seems to rely on cmake as well to find python interpreter [3].

[1] https://cmake.org/cmake/help/v3.0/module/FindPythonInterp.html
[2] https://github.com/Kitware/CMake/blob/master/Modules/FindPythonInterp.cmake
[3] https://github.com/tpaviot/pythonocc-core/blob/master/CMakeLists.txt#L117

@Stinkfist0

Copy link
Copy Markdown
Contributor

Seems that I have mixed up PYHONPATH & PYHONHOME. The latter seems to be "official" way for telling the location of python.exe, at least on Windows, so maybe better to switch to using that.

@aothms

aothms commented Feb 18, 2016

Copy link
Copy Markdown
Member Author

@Stinkfist0 I see, shall I commit a s/PYTHONPATH/PYTHONHOME/ ? Or does it need more adaptations?

@Stinkfist0

Copy link
Copy Markdown
Contributor

@aothms Sure, these places should be altered: https://github.com/IfcOpenShell/IfcOpenShell/search?utf8=✓&q=PYTHONPATH

@aothms

aothms commented Feb 18, 2016

Copy link
Copy Markdown
Member Author

Ok, doesn't seem github's search is very reliable or my patch is over-enthusiastic. Your search has 11 results, but my patch has 17 changes.

aothms added a commit that referenced this pull request Feb 18, 2016
Add option to compile (external) schema by cmake + general improvements
@aothms aothms merged commit a33f5b6 into IfcOpenShell:master Feb 18, 2016
@aothms aothms deleted the cmake_compile_schema branch February 18, 2016 14:43
@Stinkfist0

Copy link
Copy Markdown
Contributor

Note for Windows users: remember to edit existing BuilDepsCache-xYY.txt to contain PYTHONHOME instead of PYTHONPATH, or alternatively re-run build-deps.cmd

Moult added a commit that referenced this pull request May 31, 2026
Adds three knobs and three new heartbeat numbers to support the
ongoing perf-parity work. None affect behaviour in default runs.

cull[wall|compute|upload] split timer
  The existing cull_timer wrapped both the parallel std::async dispatch
  and the sequential cullModelCpuUpload loop (queueWriteBuffer × 3 per
  resident chunk × ~120 chunks ≈ 360 wgpu calls per frame). Splitting
  them ruled upload out as the bottleneck on a 51-model federation
  scene: compute ≈ 16-17 ms, upload ≈ 1 ms.

WGPU_CULL_THREADS=0 — force sequential cull
  std::async-per-model was already in place; this env var disables it
  so we can compare wall time vs sequential and confirm parallelism is
  working. On the federation scene with 52 models: sequential 74 ms vs
  parallel 17 ms = 4.4× speedup. Confirmed; the 17 ms floor is not a
  parallelism failure, it's the cost of culling the largest single
  model (model 43, 114k instances) ÷ no parallelism within that model.

WGPU_STREAM_DEBUG=1 — per-frame [stream-debug] log
  Surfaces cands/enq/drained/ev_lru/ev_pri/blocked/resident/cycled/
  max_load each frame from driveStreamingLoads. The "cycled" /
  "max_load" pair makes thrash vs eviction-churn vs just-loading
  distinguishable. Off by default; opt-in via the env var.

Bench-warm timeout dump
  When [bench warm] times out (600 frames without 0-loads streak),
  prints a structured summary: resident/missing/total chunks,
  cycled count, pool usage, largest free run, avg missing chunk
  size, and an auto-classifier diagnosis (POOL FRAGMENTED vs
  WORKING SET > POOL vs FEW-CHUNK CYCLE vs still-loading). Caught
  a real fragmentation pattern (18 MB largest free run vs ~100 MB
  typical chunk) on a 51-model run where the dumb classifier
  would have called it a load-budget problem.

LOD1 firing counter
  "lod1 X/Y (saved Z tris, N no-lod1)" suffix on the [frame] log.
  X = LOD1-selected this frame, Y = LOD1-eligible, Z = tris not
  drawn vs always-LOD0, N = visible instances with no baked LOD1
  (mesh below IFC_LOD_MIN_TRIS). Confirmed LOD1 path is genuinely
  firing post the per-chunk LOD1-storage commit, and exposed that
  ~90% of instances in real scenes are no-lod1 meshes — relevant
  to the future LOD-tier-residency design.

Chunk.load_count + Chunk.lod0/1 layout bookkeeping
  Per-chunk reload counter for the thrash detector. lod0/1
  layout_count fields prep the data model for distance-tiered
  residency (Phase B of #31) but aren't acted on yet.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Moult added a commit that referenced this pull request Jun 1, 2026
Adds three knobs and three new heartbeat numbers to support the
ongoing perf-parity work. None affect behaviour in default runs.

cull[wall|compute|upload] split timer
  The existing cull_timer wrapped both the parallel std::async dispatch
  and the sequential cullModelCpuUpload loop (queueWriteBuffer × 3 per
  resident chunk × ~120 chunks ≈ 360 wgpu calls per frame). Splitting
  them ruled upload out as the bottleneck on a 51-model federation
  scene: compute ≈ 16-17 ms, upload ≈ 1 ms.

WGPU_CULL_THREADS=0 — force sequential cull
  std::async-per-model was already in place; this env var disables it
  so we can compare wall time vs sequential and confirm parallelism is
  working. On the federation scene with 52 models: sequential 74 ms vs
  parallel 17 ms = 4.4× speedup. Confirmed; the 17 ms floor is not a
  parallelism failure, it's the cost of culling the largest single
  model (model 43, 114k instances) ÷ no parallelism within that model.

WGPU_STREAM_DEBUG=1 — per-frame [stream-debug] log
  Surfaces cands/enq/drained/ev_lru/ev_pri/blocked/resident/cycled/
  max_load each frame from driveStreamingLoads. The "cycled" /
  "max_load" pair makes thrash vs eviction-churn vs just-loading
  distinguishable. Off by default; opt-in via the env var.

Bench-warm timeout dump
  When [bench warm] times out (600 frames without 0-loads streak),
  prints a structured summary: resident/missing/total chunks,
  cycled count, pool usage, largest free run, avg missing chunk
  size, and an auto-classifier diagnosis (POOL FRAGMENTED vs
  WORKING SET > POOL vs FEW-CHUNK CYCLE vs still-loading). Caught
  a real fragmentation pattern (18 MB largest free run vs ~100 MB
  typical chunk) on a 51-model run where the dumb classifier
  would have called it a load-budget problem.

LOD1 firing counter
  "lod1 X/Y (saved Z tris, N no-lod1)" suffix on the [frame] log.
  X = LOD1-selected this frame, Y = LOD1-eligible, Z = tris not
  drawn vs always-LOD0, N = visible instances with no baked LOD1
  (mesh below IFC_LOD_MIN_TRIS). Confirmed LOD1 path is genuinely
  firing post the per-chunk LOD1-storage commit, and exposed that
  ~90% of instances in real scenes are no-lod1 meshes — relevant
  to the future LOD-tier-residency design.

Chunk.load_count + Chunk.lod0/1 layout bookkeeping
  Per-chunk reload counter for the thrash detector. lod0/1
  layout_count fields prep the data model for distance-tiered
  residency (Phase B of #31) but aren't acted on yet.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants