Skip to content

OS-allocated temp dirs with per-instance ownership - #266

Open
lm-sousa wants to merge 4 commits into
clava-simplificationfrom
dir-fixes
Open

lm-sousa wants to merge 4 commits into
clava-simplificationfrom
dir-fixes

Conversation

@lm-sousa

Copy link
Copy Markdown
Member

One policy for every temporary directory, shared by the open temp-dir issues: allocated by the OS (SpecsIo.createTempDirectory, specs-feup/specs-java-libs#34), owned by the lifecycle that created it (weaver instance, dumper invocation, test instance), and deleted when that lifecycle ends — kept for inspection in debug mode with the path logged.

Stacked on #265 (merge that one first). #188 (rebuild flakiness) should be re-verified after this change, since the shared/reused rebuild folders were a plausible cause.

Closes #251, closes #264, closes #248, closes #249, closes #205, closes #250, closes #235, closes #223.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@lm-sousa
lm-sousa added this pull request to stack #256 September 28, 2026 18:59
@lm-sousa

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f2c74c2c0c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ClavaWeaver/src/pt/up/fe/specs/clava/weaver/CxxWeaver.java Outdated
Comment thread ClangAstParser/test/pt/up/fe/specs/clang/parser/AClangAstTester.java Outdated
One policy for every temporary directory: allocated by the OS
(SpecsIo.createTempDirectory, PR from specs-java-libs), owned by the
lifecycle that created it, deleted when that lifecycle ends (kept in
debug mode for inspection, with the path reported).

- CxxWeaver: rebuild folders are now owned by the weaver instance
  instead of a static ThreadLocal<Buffer>, isolating concurrent
  weaver instances sharing one thread; the fixed cwd-relative
  '__clava_woven_for_file_rebuild' folder is now a per-invocation
  temp dir; close() no longer deletes cwd-relative '__clava_woven'
  and '__clava_src' folders, which could destroy unrelated user
  directories ('__clava_src' was already dead). Regression test
  added.
- ParallelCodeParser/ClangAstDumper: drop the 'clava_parsing_<UUID>'
  session root and the baseFolder plumbing; each dumper invocation
  owns one OS temp folder, deleted after use. Retire the now
  redundant CodeParser.CLEAN option.
- AClangAstTester: output folders are OS-allocated instead of
  '<nanoTime>-<threadId>' names in the working directory, keeping
  debug leftovers out of the repo.
- Cache root unified with Clava-JS: DUMPER_FOLDER now defaults to
  the OS user cache folder ('~/.cache/@specs-feup/clava' on Linux),
  the same location Clava-JS already used, so downloads are shared
  instead of duplicated; Clava-JS drops its own override and OS
  detection.

Addresses #251, #264, #248, #249, #205, #250
Keep the per-instance folder lifecycle from 0c3fef8 and change only the rebuild and file-include directory prefixes.
Allocate a fresh temporary directory for each rebuild, retain only the two most recent per weaver, and use SpecsIo's safe temporary-directory cleanup when retiring or closing them.
Run per-instance rebuild-folder cleanup even if close-time syntax checking fails. Allocate Clang AST test output only when the test runs so skipped CUDA tests leave no empty directory.
@sonarqubecloud

Copy link
Copy Markdown

@lm-sousa

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8685e6c557

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +36 to +39
Files.deleteIfExists(sentinelWoven.toPath());
Files.deleteIfExists(sentinelSrc.toPath());
Files.deleteIfExists(sentinelSrc.getParentFile().toPath());
Files.deleteIfExists(sentinelWoven.getParentFile().toPath());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve pre-existing directories in the regression test

When the test runs from a checkout that already contains __clava_woven or __clava_src—the exact scenario this regression is intended to protect—the setup overwrites any existing sentinel.txt, and this cleanup then deletes it and may remove an originally empty directory. If either directory contains other files, deleteIfExists also throws DirectoryNotEmptyException, failing the test during cleanup. Run the assertion in an isolated working directory or record and restore the pre-test state instead of unconditionally deleting these paths.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
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.

1 participant